<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of kron2</title>
  <meta name="keywords" content="kron2">
  <meta name="description" content="Computes the Pseudokronecker product of TT tensors:">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">@tt_tensor</a> &gt; kron2.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/@tt_tensor&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>kron2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>Computes the Pseudokronecker product of TT tensors:</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [c]=kron2(a,b) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Computes the Pseudokronecker product of TT tensors:
   [C]=KRON2(A,B)
   c{i}=kron(a{i},b{i}) &lt;- &quot;a&quot; indices vary faster!
   mode sizes and ranks are multiplied


 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@tt_matrix/size.html" class="code" title="function [sz] = size(tt)">size</a>	Mode sizes of the TT-matrix</li><li><a href="reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>	Reshape of the TT-tensor</li><li><a href="size.html" class="code" title="function [sz] = size(tt,dim)">size</a>	Mode sizes of the TT-tensor</li><li><a href="tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>	TT-tensor constructor</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [c]=kron2(a,b)</a>
0002 <span class="comment">% Computes the Pseudokronecker product of TT tensors:</span>
0003 <span class="comment">%   [C]=KRON2(A,B)</span>
0004 <span class="comment">%   c{i}=kron(a{i},b{i}) &lt;- &quot;a&quot; indices vary faster!</span>
0005 <span class="comment">%   mode sizes and ranks are multiplied</span>
0006 <span class="comment">%</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% TT-Toolbox 2.2, 2009-2012</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets et al.</span>
0011 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0012 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0013 <span class="comment">%</span>
0014 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0015 <span class="comment">%ivan.oseledets@gmail.com</span>
0016 <span class="comment">%---------------------------</span>
0017 
0018 <span class="keyword">if</span> ( isempty(a) )
0019   c=b;
0020   <span class="keyword">return</span>
0021 <span class="keyword">elseif</span> ( isempty(b) )
0022   c=a;
0023   <span class="keyword">return</span>
0024 <span class="keyword">end</span>
0025 <span class="keyword">if</span> ( <a href="size.html" class="code" title="function [sz] = size(tt,dim)">size</a>(a.core,1) == 1 ) 
0026    a.core=(a.core).';
0027 <span class="keyword">end</span>
0028 <span class="keyword">if</span> ( <a href="size.html" class="code" title="function [sz] = size(tt,dim)">size</a>(b.core,1) == 1 ) 
0029    b.core=(b.core).';
0030 <span class="keyword">end</span>
0031 
0032 d = a.d;
0033 <span class="keyword">if</span> (b.d~=d)
0034     error(<span class="string">'Could not compute kron2 from the tensors with not equal dimensions\n'</span>);
0035 <span class="keyword">end</span>;
0036 cra = a.core;
0037 na = a.n;
0038 ra = a.r;
0039 psa = a.ps;
0040 crb = b.core;
0041 nb = b.n;
0042 rb = b.r;
0043 psb = b.ps;
0044 
0045 c=<a href="tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>;
0046 n = [(na).*(nb)];
0047 r = [(ra).*(rb)];
0048 ps = cumsum([1; n.*r(2:d+1).*r(1:d)]);
0049 
0050 
0051 c.d=d;
0052 c.n=n;
0053 c.r=r;
0054 c.ps = ps;
0055 cr = zeros(ps(d+1)-1, 1);
0056 <span class="keyword">for</span> i=1:d
0057     a1 = cra(psa(i):psa(i+1)-1);
0058     b1 = crb(psb(i):psb(i+1)-1);
0059     c1 = a1*(b1.'); <span class="comment">% Size ra1*na*ra2, rb1*nb*rb2</span>
0060     c1 = <a href="reshape.html" class="code" title="function [tt2]=reshape(tt1,sz,eps, rl, rr)">reshape</a>(c1, ra(i), na(i), ra(i+1), rb(i), nb(i), rb(i+1));
0061     c1 = permute(c1, [1, 4, 2, 5, 3, 6]); <span class="comment">% We need rc1, nc*rc2</span>
0062     cr(ps(i):ps(i+1)-1) = c1(:);
0063 <span class="keyword">end</span>;
0064 
0065 c.core=cr;
0066 
0067 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>